package com.boboPlanet.user.mq.consumer;

import com.boboPlanet.comm.rabbitmq.consume.PlanetConsumeListener;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DefaultConsumer;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Description: TODO
 * @Author: mis_wu
 * @Date: 2023/6/22
 * @Company planet
 **/
@Component
@Slf4j
public class TestConsume implements PlanetConsumeListener {

    private static final String QUEUE = "test.mq.queue";


    @Override
    public String queue() {
        return QUEUE;
    }

    @Override
    public String exchange() {
        return null;
    }

    @Override
    public String routingKey() {
        return null;
    }

    @Override
    public String ackMode() {
        return "MANUAL";
    }

    @Override
//    @RabbitListener(queues = QUEUE )
    public void receive(@NotNull Message message, Channel channel, long tag) {

        //可在切面中解析数据，每个消费者直接接收即可
        String data = new String(message.getBody());

        log.info("收到测试mq消息: {}",data);
    }
}
